﻿using BW.MLTT.IRepository;
using BW.MLTT.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BW.MLTT.Service
{
    public class BaseService<T> : IBaseService<T> where T : class
    {
        private readonly IBaseRepository<T> repository;

        public BaseService(IBaseRepository<T> repository)
        {
            this.repository = repository;
        }

        public void Add(T entity)
        {
            repository.Add(entity);
        }

        public void AddRange(List<T> entity)
        {
            repository.AddRange(entity);
        }

        public void Delete(T entity)
        {
            repository.Delete(entity);
        }

        public void DeletedRange(List<T> entity)
        {
            repository.DeletedRange(entity);
        }

        public IQueryable<T> GetAll()
        {
            return repository.GetAll();
        }

        public int SaveChange()
        {
          return  repository.SaveChange();
        }

        public void Update(T entity)
        {
            repository.Update(entity);
        }

        public void UpdateRange(List<T> entity)
        {
            repository.UpdateRange(entity);
        }
    }
}
